#! /bin/sh -

userresources=$HOME/.Xresources
usermodmap=$HOME/.Xmodmap
sysresources=/etc/X11/xinit/.Xresources
sysmodmap=/etc/X11/xinit/.Xmodmap

# merge in defaults and keymaps

if [ -f $sysresources ]; then
    xrdb -merge $sysresources
fi

if [ -f $sysmodmap ]; then
    xmodmap $sysmodmap
fi

if [ -f "$userresources" ]; then
    xrdb -merge "$userresources"
fi

if [ -f "$usermodmap" ]; then
    xmodmap "$usermodmap"
fi

# To populate the user directory if needed
if test ! -d "${HOME}/.icewm"
then
    mkdir -- "${HOME}/.icewm" && \
    for file in /usr/share/icewm/*
    do
        test -f "$file" || continue;

        cat -- "$file" > "${HOME}/.icewm/${file##*/}"
    done
    unset file
fi

# Start IceWM

exec icewm-session

